<!DOCTYPE html>
<html dir="<?php echo $direction; ?>" lang="<?php echo $lang; ?>">
<head>
    <title><?php echo $title; ?></title>
    <meta name="description" content="My Store" />
    <base href="<?php echo $base; ?>" />
    <?php if ($description) { ?>
    <meta name="description" content="<?php echo $description; ?>" />
    <?php } ?>
    <?php if ($keywords) { ?>
    <meta name="keywords" content="<?php echo $keywords; ?>" />
    <?php } ?>
    <?php if ($icon) { ?>
    <link href="<?php echo $icon; ?>" rel="icon" />
    <?php } ?>
    <?php foreach ($links as $link) { ?>
    <link href="<?php echo $link['href']; ?>" rel="<?php echo $link['rel']; ?>" />
    <?php } ?>
    <link rel="stylesheet" type="text/css" href="catalog/view/theme/wenlong/stylesheet/stylesheet.css" />
    <!--[if lt IE 7]>
    <link rel="stylesheet" type="text/css" href="catalog/view/theme/wenlong/stylesheet/ie6.css" />
    <script type="text/javascript" src="catalog/view/javascript/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>
        DD_belatedPNG.fix('img, #header .div3 a, #content .left, #content .right, .box .top');
    </script>
    <![endif]-->
    <script type="text/javascript" src="catalog/view/javascript/jquery/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="catalog/view/javascript/jquery/thickbox/thickbox-compressed.js"></script>
    <link rel="stylesheet" type="text/css" href="catalog/view/javascript/jquery/thickbox/thickbox.css" />
    <script type="text/javascript" src="catalog/view/javascript/jquery/tab.js"></script>
    <script type="text/javascript" src="catalog/view/javascript/common.js"></script>
    <?php foreach ($scripts as $script) { ?>
    <script type="text/javascript" src="<?php echo $script; ?>"></script>
    <?php } ?>
    <script type="text/javascript"><!--
    function bookmark(url, title) {
        if (window.sidebar) { // firefox
            window.sidebar.addPanel(title, url, "");
        } else if(window.opera && window.print) { // opera
            var elem = document.createElement('a');
            elem.setAttribute('href',url);
            elem.setAttribute('title',title);
            elem.setAttribute('rel','sidebar');
            elem.click();
        } else if(document.all) {// ie
   		window.external.AddFavorite(url, title);
	}
                }
    //--></script>
    <?php echo $google_analytics; ?>
</head>
<body>
<div id="container">
    <div id="header">
        <div class="div1">
            <div class="div2">
                <?php if ($logo) { ?>
                <a href="<?php echo $home; ?>"><img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a>
                <?php }?>
            </div>
            <div class="div3">
                <a href="<?php echo $special; ?>" style="background-image: url('catalog/view/theme/wenlong/image/special.png');"><?php echo $text_special; ?></a>
                    <a onclick="bookmark(document.location, '<?php echo $title; ?>');" style="background-image: url('catalog/view/theme/wenlong/image/bookmark.png');"><?php echo $text_bookmark; ?></a>
                <a href="<?php echo $contact; ?>" style="background-image: url('catalog/view/theme/wenlong/image/contact.png');"><?php echo $text_contact; ?></a>
                <a href="<?php echo $sitemap; ?>" style="background-image: url('catalog/view/theme/wenlong/image/sitemap.png');"><?php echo $text_sitemap; ?></a></div>

            <div class="div4">
                <a href="<?php echo $home; ?>" id="tab_home"><?php echo $text_home; ?></a>
                <?php if (!$logged) { ?>
                    <?php echo $text_welcome; ?>
                    <?php } else { ?>
                    <?php echo $text_logged; ?>
                    <?php } ?>
                </a>
                <a href="<?php echo $account; ?>" id="tab_account"><?php echo $text_account; ?></a>
                <a href="<?php echo $nav_cart; ?>" id="tab_cart"><?php echo $text_cart; ?></a>
                <a href="<?php echo $checkout; ?>" id="tab_checkout"><?php echo $text_checkout; ?></a>
            </div>
            <div class="div5">
                <div class="left"></div>
                <div class="right"></div>
                <div class="center">
                    <div id="search">
                        <div class="div8"><?php echo $text_search; ?>:&nbsp;</div>
                        <div class="div9">
                            <input type="text" style="color: #999;" name="filter_name" value="<?php echo $text_input_search; ?>" onclick="this.value = '';" onkeydown="this.style.color = '#000000';" />
                            <select id="filter_category_id">
                                <option value="0"><?php echo $text_category;?></option>
                                <?php  if ($categories_nav) { ?>
                                    <?php foreach ($categories_nav as $category) { ?>
                                        <option value="<?php echo $category['category_id']; ?>">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $category['name']; ?></option>
                                            <?php if ($category['children']) { ?>
                                            <?php for ($i = 0; $i < count($category['children']);$i++) { ?>
                                            <option value="<?php echo $category['children'][$i]['category_id'];?>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $category['children'][$i]['name']; ?></option>
                                            <?php } ?>
                                        <?php } ?>
                                    <?php } ?>
                                <?php } ?>
                            </select>
                        </div>
                        <div class="div10">&nbsp;&nbsp;<a onclick="moduleSearch();" class="button"><span><?php echo $button_continue; ?></span></a>
                            <a href="<?php echo $advanced;?>"><?php echo $text_advanced; ?></a></div>
                    </div>
                </div>
            </div>
        </div>
        <div class="div6">
            <div class="left"></div>
            <div class="right"></div>
            <div class="center">
                <div id="breadcrumb">
                </div>
                <div class="div7">
                    <?php echo $currency; ?>
                    <?php echo $language; ?>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript"><!--
    function getURLVar(urlVarName) {
        var urlHalves = String(document.location).toLowerCase().split('?');
        var urlVarValue = '';

        if (urlHalves[1]) {
            var urlVars = urlHalves[1].split('&');

            for (var i = 0; i <= (urlVars.length); i++) {
                if (urlVars[i]) {
                    var urlVarPair = urlVars[i].split('=');

                    if (urlVarPair[0] && urlVarPair[0] == urlVarName.toLowerCase()) {
                        urlVarValue = urlVarPair[1];
                    }
                }
            }
        }

        return urlVarValue;
    }

    $(document).ready(function() {

        route = getURLVar('route');

        if (!route) {
            $('#tab_home').addClass('selected');

        } else {

            part = route.split('/');
            if (route == 'common/home') {
                $('#tab_home').addClass('selected');
            } else if (route == 'account/login') {
                $('#tab_login').addClass('selected');
            } else if (part[0] == 'account') {
                $('#tab_account').addClass('selected');
            } else if (route == 'checkout/cart') {
                $('#tab_cart').addClass('selected');
            } else if (part[0] == 'checkout') {
                $('#tab_checkout').addClass('selected');
            } else {
                $('#tab_home').addClass('selected');
            }
        }
    });
    //--></script>
    <script type="text/javascript"><!--
    $('#search input').keydown(function(e) {
        if (e.keyCode == 13) {
            moduleSearch();
        }
    });

    function moduleSearch() {
        pathArray = location.pathname.split( '/' );

        url = '<?php echo HTTP_SERVER; ?>';

        url += 'index.php?route=product/search';

        var filter_keyword = $('#filter_keyword').attr('value')

        if (filter_keyword) {
            url += '&keyword=' + encodeURIComponent(filter_keyword);
        }

        var filter_category_id = $('#filter_category_id').attr('value');

        if (filter_category_id) {
            url += '&category_id=' + filter_category_id;
        }

        location = url;
    }
    //--></script>
    <script type="text/javascript"><!--
    $('.switcher').bind('click', function() {
        $(this).find('.option').slideToggle('fast');
    });
    $('.switcher').bind('mouseleave', function() {
        $(this).find('.option').slideUp('fast');
    });
    //--></script>